﻿// -----------------------------------------------------------------------
// <copyright file="WebResourceManager.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace NetFramework.Web
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class WebResourceManager
    {
        public static string Get(string key)
        {
            string value = RouteManager.Get(key);
            if (string.IsNullOrEmpty(value))
            {
                value = QueryStringManager.Get(key);
                if (string.IsNullOrEmpty(value))
                {
                    value = FormManager.Get(key);
                }
            }

            return value;
        }

        public static T Get<T>(string key)
        {
            return Get<T>(key, default(T));
        }

        public static T Get<T>(string key, T defaultValue)
        {
            T value = RouteManager.Get<T>(key, defaultValue);
            if (value.Equals(defaultValue))
            {
                value = QueryStringManager.Get<T>(key);
                if (value.Equals(defaultValue))
                {
                    value = FormManager.Get<T>(key);
                }
            }

            return value;
        }
    }
}
